# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
from trinity import __version__ as version

project = "Trinity-RFT"
copyright = "2025, Trinity-RFT Team"
author = "Trinity-RFT Team"
release = version

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
    "sphinxcontrib.apidoc",
    "sphinx.ext.autodoc",
    "sphinx.ext.autosummary",
    "sphinx.ext.viewcode",
    "sphinx.ext.napoleon",
    "sphinx.ext.autosectionlabel",
    "sphinx_multiversion",
    "myst_parser",
    "sphinx.ext.mathjax",
]
source_suffix = {
    ".rst": "restructuredtext",
    ".md": "markdown",
}
myst_enable_extensions = ["colon_fence", "amsmath", "dollarmath"]

# Prefix document path to section labels, otherwise autogenerated labels would
# look like 'heading' rather than 'path/to/file:heading'
autosectionlabel_prefix_document = True
autosummary_generate = True
autosummary_ignore_module_all = False
napoleon_google_docstring = True

autodoc_member_order = "bysource"

templates_path = ["_templates"]
exclude_patterns = ["build"]

autodoc_default_options = {
    "members": True,
    "special-members": "__init__",
}

# auto api configs
apidoc_module_dir = "../../../trinity"
apidoc_output_dir = "build_api"
apidoc_excluded_paths = ["tests", "build"]
apidoc_separate_modules = True

# Multiversion configs
smv_tag_whitelist = r"^v\d+\.\d+\.\d+$"  # match v1.0.0 pattern
smv_branch_whitelist = r"^(main)$"  # included branches
smv_remote_whitelist = None
smv_released_pattern = r"^tags/.*$"

smv_prefer_remote_refs = False

# -- Options for HTML output -------------------------------------------------

html_theme = "sphinx_book_theme"

html_logo = "_static/logo.svg"

html_theme_options = {
    "navigation_depth": 3,
}

html_sidebars = {
    "**": [
        "navbar-logo.html",
        "icon-links.html",
        "versions.html",
        "search-button-field.html",
        "sbt-sidebar-nav.html",
    ]
}

html_context = {
    "display_github": True,
    "github_user": "modelscope",
    "github_repo": "Trinity-RFT",
    "github_version": "main",
    "conf_py_path": "/docs/sphinx_doc/source/",
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
